/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "area_atuacao", catalog = "carlossa03", schema = "")
@NamedQueries({@NamedQuery(name = "AreaAtuacao.findAll", query = "SELECT a FROM AreaAtuacao a"), @NamedQuery(name = "AreaAtuacao.findByAreaAtuacaoId", query = "SELECT a FROM AreaAtuacao a WHERE a.areaAtuacaoId = :areaAtuacaoId"), @NamedQuery(name = "AreaAtuacao.findByNome", query = "SELECT a FROM AreaAtuacao a WHERE a.nome = :nome")})
public class AreaAtuacao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "area_atuacao_id")
    private Integer areaAtuacaoId;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "areaAtuacaoId", fetch = FetchType.LAZY)
    private List<Empresa> empresaCollection;

    public AreaAtuacao() {
    }

    public AreaAtuacao(Integer areaAtuacaoId) {
        this.areaAtuacaoId = areaAtuacaoId;
    }

    public AreaAtuacao(Integer areaAtuacaoId, String nome) {
        this.areaAtuacaoId = areaAtuacaoId;
        this.nome = nome;
    }

    public Integer getAreaAtuacaoId() {
        return areaAtuacaoId;
    }

    public void setAreaAtuacaoId(Integer areaAtuacaoId) {
        this.areaAtuacaoId = areaAtuacaoId;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public List<Empresa> getEmpresaCollection() {
        return empresaCollection;
    }

    public void setEmpresaCollection(List<Empresa> empresaCollection) {
        this.empresaCollection = empresaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (areaAtuacaoId != null ? areaAtuacaoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AreaAtuacao)) {
            return false;
        }
        AreaAtuacao other = (AreaAtuacao) object;
        if ((this.areaAtuacaoId == null && other.areaAtuacaoId != null) || (this.areaAtuacaoId != null && !this.areaAtuacaoId.equals(other.areaAtuacaoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNome();
    }

}
